public class Ln
extends java.lang.Object
| Constructor and Description |
|---|
Ln() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
arrayPrintInts(int[] input)
Prints the integer representation of each index in the array.
|
static int |
arrayToInt(byte[] input)
Converts byte array to a single int, assuming little endian.
|
static int |
arrayToInt(int[] input)
Converts int array to a single int, assuming little endian.
|
static long |
arrayToLong(byte[] input)
Converts byte array to a single long, assuming little endian.
|
static long |
arrayToLong(int[] input)
Converts int array to a single long, assuming little endian.
|
static java.lang.String |
arrayToString(byte[] input)
Converts a byte array to its string equivalent.
|
static java.lang.String |
arrayToString(int[] input)
Converts an int array to its string equivalent.
|
static int |
bToUInt(byte in)
Converts a byte to an unsigned integer.
|
static java.lang.String |
center(int spaces,
char c,
java.lang.String... input)
Centers the input inside desired width.
|
static java.lang.String |
changeFileTypeTo(java.lang.String input,
java.lang.String type)
Replaces the suffix with the desired suffix.
|
static java.lang.String |
cleanLine(java.lang.String line,
java.lang.String comment)
Removes comments, and trims whitespace
|
static boolean |
contains(java.util.ArrayList<java.lang.String> list,
java.lang.String s)
True if list has a string that contains s.
|
static boolean |
containsEqualsIgnoreCase(java.util.ArrayList<java.lang.String> list,
java.lang.String s)
True if list has a string equaling s, ignoring case.
|
static boolean |
containsIgnoreCase(java.util.ArrayList<java.lang.String> list,
java.lang.String s) |
static java.lang.String |
convertBoolTo1(java.lang.Boolean input)
Converts boolean to "1" or "0"
|
static java.lang.String |
convertBoolTo1(java.lang.String input)
Converts "true" to "1" and "false" to "0"
|
static java.lang.String |
convertStreamToStr(java.io.InputStream is)
Exports contents of a stream to a string.
|
static void |
copyFile(java.io.File sourceFile,
java.io.File destFile) |
static void |
copyFileToDir(java.io.File sourceFile,
java.io.File destDir) |
static java.lang.Object |
deepCopy(java.lang.Object orig)
Returns a copy of the object, or null if the object cannot be serialized.
|
static boolean |
deleteDirectory(java.io.File directory)
Removes the directory and everything inside of it.
|
static boolean |
equals(java.util.ArrayList lhs,
java.util.ArrayList rhs,
boolean ordered)
Tests whether two array lists have equal contents.
|
static void |
expandAll(javax.swing.JTree tree,
boolean expand)
Expands or minimizes all nodes in a GUI tree.
|
static void |
expandToDepth(javax.swing.JTree tree,
int depth) |
static java.io.File[] |
fileDialog()
Opens a file dialog for user to pick files.
|
static int |
gcd(int... nums) |
static int |
gcd(int a,
int b)
Returns the greatest common denominator.
|
static java.util.ArrayList<java.io.File> |
generateFileList(java.io.File src,
boolean addDirs)
Recursively returns all files inside of a directory and its
subdirectories.
|
static java.util.ArrayList<java.io.File> |
generateFileList(java.io.File src,
int minDepth,
int maxDepth,
boolean addDirs)
Recursively returns all files inside of a directory and its
subdirectories.
Has min/max depths to exclude undesired levels. |
static java.lang.String |
get(java.lang.String[] arr,
java.lang.String target) |
static java.util.ArrayList<java.lang.String> |
getClasses(java.io.File jarPath)
A list of all the class files in a jar.
|
static java.lang.String |
getExpansionState(javax.swing.JTree tree,
int row)
Returns a string representation of the tree's expansion state.
|
static java.io.File |
getFilepathCaseInsensitive(java.io.File test)
Returns an uppercase version of the test path if it exists.
|
static java.lang.String |
getFileType(java.io.File f)
Returns the file extension string.
|
static java.io.File |
getMyDocuments() |
static java.lang.String |
getNAmount(int n,
java.lang.String s)
Gets a string containing N number of String s.
|
static boolean |
hasAnyKeywords(java.lang.String target,
java.util.ArrayList<java.lang.String> keywords)
Checks string to see if it contains any of the keywords in the arraylist.
|
static int |
indexOfContains(java.util.ArrayList<java.lang.String> list,
java.lang.String s)
Returns the first index that has a string containing s.
|
static int |
indexOfIgnoreCase(java.util.ArrayList<java.lang.String> list,
java.lang.String s)
A contains() check that's case insensitive.
|
static java.lang.String |
insertInStr(java.lang.String input,
java.lang.String insert,
int location)
Inserts a string inside the input string at the given index.
|
static boolean |
isDescendant(javax.swing.tree.TreePath parent,
javax.swing.tree.TreePath child) |
static boolean |
isFileCaseInsensitive(java.io.File test)
Returns true if input is a file (case insensitive check)
|
static boolean |
isFileType(java.io.File f,
java.lang.String fileType)
True if file extension is equal to input, case insensitive.
|
static int |
lcm(int a,
int b)
Returns least common multiple
|
static int |
lcmm(int... nums)
Returns least common multiple
|
static java.util.ArrayList<java.lang.Class> |
loadClasses(java.io.File jarPath,
boolean skipBad)
loads all classes in a jar.
|
static java.util.ArrayList<java.lang.String> |
loadFileToStrings(java.io.File f,
boolean toUpper)
Opens a file and loads in each line.
|
static java.util.ArrayList<java.lang.String> |
loadFileToStrings(java.lang.String path,
boolean toUpper)
Opens a file and loads in each line.
|
static void |
makeDirs(java.io.File file)
Makes the directories associated with a file.
|
static void |
makeDirs(java.lang.String file)
Makes the directories associated with a file.
|
static java.io.File |
manualFindFile(java.lang.String fileMessageToAskUserFor,
java.io.File backupFileLocation)
Asks the user to locate a file, and saves the location for next time.
|
static boolean |
moveFile(java.io.File src,
java.io.File dest,
boolean eraseOldDirs)
Moves a file from one directory to another.
|
static java.lang.String |
nanoTimeString(long nanoseconds)
Print nanoseconds to a m:s format.
|
static byte[] |
parseHexString(java.lang.String hex)
Parses a hex string.
Viable formats: 1) "0123" 2) "01 23" 3) "0x01 0x23" |
static byte[] |
parseHexString(java.lang.String hex,
int min)
Parses a hex string.
Viable formats: 1) "0123" 2) "01 23" 3) "0x01 0x23" |
static byte[] |
parseHexString(java.lang.String hex,
int min,
boolean reverse)
Parses a hex string.
Viable formats: 1) "0123" 2) "01 23" 3) "0x01 0x23" |
static java.lang.String |
prettyPrintHex(int input)
Prints input in the form of: "([integer representation]->[hex
representation])"
|
static java.lang.String |
prettyPrintHex(long input)
Prints input in the form of: "([integer representation]->[hex
representation])"
|
static java.lang.String |
printDouble(double in,
int length)
Prints a double in digit form, no scientific notation.
|
static java.lang.String |
printHex(byte[] input,
java.lang.Boolean space,
java.lang.Boolean reverse)
Prints the hex string of the input
|
static java.lang.String |
printHex(int input)
Prints the hex string of the input (assuming its one byte)
|
static java.lang.String |
printHex(int[] input,
java.lang.Boolean space,
java.lang.Boolean reverse)
Prints the hex string of the input
|
static java.lang.String |
printHex(int input,
java.lang.Boolean space,
java.lang.Boolean reverse,
int minLength)
Prints the hex string of the input
|
static java.lang.String |
printHex(java.lang.Integer[] input,
java.lang.Boolean space,
java.lang.Boolean reverse)
Prints the hex string of the input
|
static java.lang.String |
printHex(long input)
Prints the hex string of the input (assuming its one byte)
|
static java.lang.String |
removeFromStr(java.lang.String input,
java.lang.String remove)
Removes all instances of the remove string from the input string.
|
static boolean |
removeIgnoreCase(java.util.ArrayList<java.lang.String> list,
java.lang.String s) |
static void |
restoreExpanstionState(javax.swing.JTree tree,
int row,
java.lang.String expansionState)
Restores a tree's expansion state to a previously saved string
representation.
|
static byte[] |
reverse(byte[] input)
Reverses bytes in a byte array
|
static char[] |
reverse(char[] input)
Reverses characters in a char array
|
static int[] |
reverse(int[] input)
Reverses integers in an int array
|
static java.lang.String |
reverse(java.lang.String input)
Reverse characters in the string
|
static java.io.File |
setupFile(java.io.File f,
java.lang.Boolean delete)
Make directories to file path if they don't exist.
Deletes old file if delete is on. |
static java.io.File |
setupFile(java.lang.String s,
java.lang.Boolean delete)
Make directories to file path if they don't exist.
Deletes old file if delete is on. |
static java.lang.String |
spaceLeft(java.lang.Boolean enforce,
int spaces,
char c,
java.lang.String... input)
Takes the input and adds the desired amount of spaces to get the end
result of being "spaces" wide.
|
static java.lang.String |
spaceRight(int spaces,
char c,
java.lang.String... input)
Takes the input and adds the desired amount of spaces to get the end
result of being "spaces" wide.
|
static java.lang.String |
standardizeFilePath(java.lang.String filePath)
Replaces "\\" with "/"
|
static java.lang.Boolean |
toBool(java.lang.String input) |
static byte[] |
toByteArray(int input) |
static byte[] |
toByteArray(int[] input) |
static byte[] |
toByteArray(int input,
int size) |
static byte[] |
toByteArray(int input,
int minLength,
int maxLength) |
static byte[] |
toByteArray(long input,
int minLength,
int maxLength) |
static byte[] |
toByteArray(java.lang.String input)
Converts string to a byte array with no null terminator.
|
static int[] |
toIntArray(byte[] in)
Converts to int array
|
static int[] |
toIntArray(int input) |
static int[] |
toIntArray(int input,
int minLength) |
static int[] |
toIntArray(int input,
int minLength,
int maxLength) |
static int[] |
toIntArray(long input) |
static int[] |
toIntArray(long input,
int minLength,
int maxLength) |
static int[] |
toIntArray(java.lang.String input) |
static java.lang.String |
toJsonPretty(com.google.gson.JsonElement object,
java.lang.String... exclude)
Custom JSON parser that exports it as a JSON file string.
|
static long |
toKB(long numBytes)
Converts byte number to kilobyte number
|
static long |
toMB(long numBytes)
Converts byte number to megabyte number
|
static java.util.ArrayList<java.lang.String> |
toUpper(java.util.ArrayList<java.lang.String> in)
Makes every item in the ArrayList uppercase
|
static java.lang.String[] |
toUpper(java.lang.String[] in) |
static boolean |
validateCompare(java.io.File testFile,
java.io.File keyFile,
int numErrorsToPrint)
A simple comparison function that compares two files byte by byte, and
reports the positions of any differences (eg.
|
static boolean |
validateCompare(java.lang.String testFile,
java.lang.String keyFile,
int numErrorsToPrint)
A simple comparison function that compares two files byte by byte, and
reports the positions of any differences (eg.
|
static void |
writeStringsToFile(java.lang.String path,
java.util.ArrayList<java.lang.String> strs) |
public static java.io.File getMyDocuments()
public static java.lang.Object deepCopy(java.lang.Object orig)
orig - Object to copypublic static java.lang.String spaceLeft(java.lang.Boolean enforce,
int spaces,
char c,
java.lang.String... input)
enforce - Whether to shrink the input to enforce the spaces size, or
let it bleed over to print all of the inputspaces - Width desired including spaces + input.c - Character to print to achieve desired width.input - Input to print.public static java.lang.String spaceRight(int spaces,
char c,
java.lang.String... input)
spaces - Width desired including spaces + input.c - Character to print to achieve desired width.input - Input to print.public static java.lang.String center(int spaces,
char c,
java.lang.String... input)
spaces - Width desired.c - Character to fill to the widthinput - Input to center.public static java.lang.String reverse(java.lang.String input)
input - public static char[] reverse(char[] input)
input - public static int[] reverse(int[] input)
input - public static byte[] reverse(byte[] input)
input - public static java.lang.String cleanLine(java.lang.String line,
java.lang.String comment)
line - comment - public static boolean deleteDirectory(java.io.File directory)
directory - public static void makeDirs(java.io.File file)
file - public static boolean equals(java.util.ArrayList lhs,
java.util.ArrayList rhs,
boolean ordered)
lhs - rhs - ordered - Whether the contents have to be in order to count as
"equal"public static void makeDirs(java.lang.String file)
file - public static boolean moveFile(java.io.File src,
java.io.File dest,
boolean eraseOldDirs)
src - Source filedest - Destination fileeraseOldDirs - Whether to erase old empty directories.public static java.util.ArrayList<java.io.File> generateFileList(java.io.File src,
int minDepth,
int maxDepth,
boolean addDirs)
src - Folder to recursively searchminDepth - Min depth to start adding file to the listmaxDepth - Max depth to add files to the listaddDirs - Include directories as files in the list, followed by
their contents.public static java.util.ArrayList<java.io.File> generateFileList(java.io.File src,
boolean addDirs)
src - Folder to recursively searchaddDirs - Include directories as files in the list, followed by
their contents.public static java.lang.String arrayToString(int[] input)
input - public static java.lang.String arrayToString(byte[] input)
input - public static boolean isFileCaseInsensitive(java.io.File test)
test - File to check if existspublic static java.io.File getFilepathCaseInsensitive(java.io.File test)
test - public static int arrayToInt(int[] input)
input - public static long arrayToLong(int[] input)
input - public static int arrayToInt(byte[] input)
input - public static long arrayToLong(byte[] input)
input - public static java.lang.String arrayPrintInts(int[] input)
input - public static java.lang.String printHex(long input)
input - public static java.lang.String printHex(int input)
input - public static java.lang.String printHex(int input,
java.lang.Boolean space,
java.lang.Boolean reverse,
int minLength)
input - integer to printspace - Adds spaces in between bytesreverse - Reverses byte printoutminLength - Will add filler zeros to achieve min lengthpublic static java.lang.String printHex(byte[] input,
java.lang.Boolean space,
java.lang.Boolean reverse)
input - array to printspace - Adds spaces in between bytesreverse - Reverses byte printoutpublic static java.lang.String printHex(java.lang.Integer[] input,
java.lang.Boolean space,
java.lang.Boolean reverse)
input - array to printspace - Adds spaces in between bytesreverse - Reverses byte printoutpublic static java.lang.String printHex(int[] input,
java.lang.Boolean space,
java.lang.Boolean reverse)
input - array to printspace - Adds spaces in between bytesreverse - Reverses byte printoutpublic static java.lang.String prettyPrintHex(int input)
input - Number to printpublic static java.lang.String prettyPrintHex(long input)
input - Number to printpublic static java.lang.String printDouble(double in,
int length)
in - Double to print.length - number of characters to print.public static java.lang.String getFileType(java.io.File f)
f - public static boolean isFileType(java.io.File f,
java.lang.String fileType)
f - fileType - public static java.lang.String removeFromStr(java.lang.String input,
java.lang.String remove)
input - Source stringremove - String to removepublic static java.lang.String insertInStr(java.lang.String input,
java.lang.String insert,
int location)
input - Source stringinsert - String to insertlocation - index to insert at.public static java.lang.String convertBoolTo1(java.lang.String input)
input - public static java.lang.String convertBoolTo1(java.lang.Boolean input)
input - public static java.lang.Boolean toBool(java.lang.String input)
input - public static java.io.File setupFile(java.io.File f,
java.lang.Boolean delete)
f - delete - public static java.io.File setupFile(java.lang.String s,
java.lang.Boolean delete)
s - delete - public static void expandAll(javax.swing.JTree tree,
boolean expand)
tree - expand - public static void expandToDepth(javax.swing.JTree tree,
int depth)
tree - depth - public static byte[] parseHexString(java.lang.String hex,
int min,
boolean reverse)
hex - Hex string to parse.min - Minimum length, will be filled with zeros to fill.reverse - Reverse the bytespublic static byte[] parseHexString(java.lang.String hex)
hex - Hex string to parse.public static byte[] parseHexString(java.lang.String hex,
int min)
hex - Hex string to parse.min - Minimum length, will be filled with zeros to fill.public static int bToUInt(byte in)
in - public static int[] toIntArray(byte[] in)
in - public static int[] toIntArray(java.lang.String input)
input - public static int[] toIntArray(int input)
input - public static int[] toIntArray(int input,
int minLength,
int maxLength)
input - minLength - maxLength - public static int[] toIntArray(int input,
int minLength)
input - minLength - public static int[] toIntArray(long input)
input - public static int[] toIntArray(long input,
int minLength,
int maxLength)
input - minLength - maxLength - public static byte[] toByteArray(int[] input)
input - public static byte[] toByteArray(int input)
input - public static byte[] toByteArray(int input,
int size)
input - size - public static byte[] toByteArray(int input,
int minLength,
int maxLength)
input - minLength - maxLength - public static byte[] toByteArray(long input,
int minLength,
int maxLength)
input - minLength - maxLength - public static byte[] toByteArray(java.lang.String input)
input - public static java.lang.String nanoTimeString(long nanoseconds)
nanoseconds - public static java.lang.String changeFileTypeTo(java.lang.String input,
java.lang.String type)
input - type - public static int gcd(int a,
int b)
a - b - public static int gcd(int... nums)
public static int lcm(int a,
int b)
a - b - public static int lcmm(int... nums)
nums - public static long toMB(long numBytes)
numBytes - public static long toKB(long numBytes)
numBytes - public static java.io.File manualFindFile(java.lang.String fileMessageToAskUserFor,
java.io.File backupFileLocation)
throws java.io.FileNotFoundException,
java.io.IOException
fileMessageToAskUserFor - backupFileLocation - java.io.FileNotFoundExceptionjava.io.IOExceptionpublic static java.io.File[] fileDialog()
public static void copyFile(java.io.File sourceFile,
java.io.File destFile)
throws java.io.IOException
sourceFile - destFile - java.io.IOExceptionpublic static void copyFileToDir(java.io.File sourceFile,
java.io.File destDir)
throws java.io.IOException
sourceFile - destDir - java.io.IOExceptionpublic static boolean validateCompare(java.io.File testFile,
java.io.File keyFile,
int numErrorsToPrint)
throws java.io.FileNotFoundException,
java.io.IOException
testFile - File to test to keyFile.keyFile - Validation file to be used as a desired example.numErrorsToPrint - Number of differences to print.java.io.FileNotFoundExceptionjava.io.IOExceptionpublic static boolean validateCompare(java.lang.String testFile,
java.lang.String keyFile,
int numErrorsToPrint)
throws java.io.FileNotFoundException,
java.io.IOException
testFile - File to test to keyFile.keyFile - Validation file to be used as a desired example.numErrorsToPrint - Number of differences to print.java.io.FileNotFoundExceptionjava.io.IOExceptionpublic static boolean isDescendant(javax.swing.tree.TreePath parent,
javax.swing.tree.TreePath child)
parent - child - public static java.lang.String getExpansionState(javax.swing.JTree tree,
int row)
tree - row - public static void restoreExpanstionState(javax.swing.JTree tree,
int row,
java.lang.String expansionState)
tree - row - expansionState - public static java.util.ArrayList<java.lang.String> getClasses(java.io.File jarPath)
throws java.io.FileNotFoundException,
java.io.IOException
jarPath - java.io.FileNotFoundExceptionjava.io.IOExceptionpublic static java.util.ArrayList<java.lang.Class> loadClasses(java.io.File jarPath,
boolean skipBad)
throws java.net.MalformedURLException,
java.io.FileNotFoundException,
java.io.IOException,
java.lang.ClassNotFoundException
jarPath - skipBad - java.net.MalformedURLExceptionjava.io.FileNotFoundExceptionjava.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic static java.lang.String convertStreamToStr(java.io.InputStream is)
throws java.io.IOException
is - java.io.IOExceptionpublic static java.lang.String toJsonPretty(com.google.gson.JsonElement object,
java.lang.String... exclude)
object - exclude - public static java.util.ArrayList<java.lang.String> loadFileToStrings(java.io.File f,
boolean toUpper)
throws java.io.IOException
f - toUpper - java.io.IOExceptionpublic static java.util.ArrayList<java.lang.String> loadFileToStrings(java.lang.String path,
boolean toUpper)
throws java.io.IOException
path - toUpper - java.io.IOExceptionpublic static void writeStringsToFile(java.lang.String path,
java.util.ArrayList<java.lang.String> strs)
throws java.io.IOException
path - strs - java.io.IOExceptionpublic static java.util.ArrayList<java.lang.String> toUpper(java.util.ArrayList<java.lang.String> in)
in - public static java.lang.String[] toUpper(java.lang.String[] in)
in - public static java.lang.String get(java.lang.String[] arr,
java.lang.String target)
arr - target - public static boolean hasAnyKeywords(java.lang.String target,
java.util.ArrayList<java.lang.String> keywords)
target - keywords - public static java.lang.String standardizeFilePath(java.lang.String filePath)
filePath - public static int indexOfContains(java.util.ArrayList<java.lang.String> list,
java.lang.String s)
list - s - public static boolean contains(java.util.ArrayList<java.lang.String> list,
java.lang.String s)
list - s - public static boolean containsIgnoreCase(java.util.ArrayList<java.lang.String> list,
java.lang.String s)
public static boolean containsEqualsIgnoreCase(java.util.ArrayList<java.lang.String> list,
java.lang.String s)
list - s - public static int indexOfIgnoreCase(java.util.ArrayList<java.lang.String> list,
java.lang.String s)
list - s - public static boolean removeIgnoreCase(java.util.ArrayList<java.lang.String> list,
java.lang.String s)
list - s - public static java.lang.String getNAmount(int n,
java.lang.String s)
n - s -